package com.cwits.wifi.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cwits.wifi.R;


/**
 * Created by ZhangHua on 16-03-01.
 */
public class PhoDialog extends Dialog {

    private ImageView mIm;
    private TextView mTvType, mTvOk;
    private RelativeLayout mRlOk;
    private RelativeLayout mRlCancle;

    public PhoDialog(Context context, boolean type, View.OnClickListener itemsOnClick) {
        super(context, R.style.MyDialog);
        setContentView(R.layout.dialog_error_btn2);

        this.setCanceledOnTouchOutside(false);
        this.setCancelable(false);

        Window window = getWindow();
        WindowManager.LayoutParams params = window.getAttributes();
        params.gravity = Gravity.CENTER;
        window.setAttributes(params);

        mIm = (ImageView) findViewById(R.id.dialog_btn2_im);
        mTvType = (TextView) findViewById(R.id.dialog_btn2_tv_info);
        mRlOk = (RelativeLayout) findViewById(R.id.dialog_btn2_rl_ok);
        mRlCancle = (RelativeLayout) findViewById(R.id.dialog_btn2_rl_canale);
        mTvOk = (TextView) findViewById(R.id.dialog_btn2_tv_ok);

        if (type) {
            mIm.setImageResource(R.mipmap.icon_load_success);
            mTvType.setText(context.getString(R.string.dialog_xzwc));
            mTvOk.setText(context.getString(R.string.dialog_ljck));
        } else {
            mIm.setImageResource(R.mipmap.icon_load_unfinished);
            mTvType.setText(context.getString(R.string.dialog_xzww));
            mTvOk.setText(context.getString(R.string.confirm));
        }
        mRlOk.setOnClickListener(itemsOnClick);
        mRlCancle.setOnClickListener(itemsOnClick);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


    }

    @Override
    public void show() {
        if (this.isShowing())
            return;
        super.show();
    }
}
